package net.seehealth.healthpad.ui;

import android.text.Html;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AdapterView;
import android.widget.ImageButton;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import net.seehealth.healthpad.R;
import net.seehealth.healthpad.application.adapter.GridViewAdapter;

public class SelfDetectionActivity extends GridViewActivity{
	
	/*********关闭按钮**************/
	private ImageButton mClose_btn;
	
	/**
	 * 上传text
	 */
	private TextView mUpload_text;
	
	/**
	 * 收缩压text
	 */
	private TextView mSystolic_pressure_text;
	
	/**
	 * 舒张压
	 */
	private TextView mDiastolic_pressure_text;
	
	@Override
	protected void initData() {
		int[] ids = new int []{1,1,1,1,1,1,1,1,1};
		String[] contents = {"已匹配设置",
				"已匹配设置",
				"已匹配设置",
				"已匹配设置",
				"已匹配设置",
				"已匹配设置",
				"已匹配设置",
				"已匹配设置",
				"已匹配设置"};
		int[] imgs = new int[] { R.drawable.gridview_blood_pressure,
				R.drawable.gridview_blood_sugar, R.drawable.gridview_weight_fat,
				R.drawable.gridview_energy_consume, R.drawable.gridview_ecg,
				R.drawable.gridview_lipids, R.drawable.gridview_sleeping,
				R.drawable.gridview_fetal, R.drawable.gridview_urine};
		
		mGridViewAdapter = new GridViewAdapter(this, contents, imgs, ids, true);
		mGridView.setAdapter(mGridViewAdapter);
		mGridView.setOnItemClickListener(onItemClick);
	}
 
	OnItemClickListener onItemClick = new OnItemClickListener() {

		@Override
		public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
				long arg3) {
			showPopWindowAmini(R.layout.blood_pressure_self_testing_pop,mGridView,0,0);
		    mClose_btn = (ImageButton)vPopupWindow.findViewById(R.id.pop_close_btn);
			mClose_btn.setOnClickListener(click);
		/*	mUpload_text = (TextView)vPopupWindow.findViewById(R.id.pop_upload_text);
			mSystolic_pressure_text = (TextView)vPopupWindow.findViewById(R.id.pop_systolic_pressure_text);
			mDiastolic_pressure_text = (TextView)vPopupWindow.findViewById(R.id.pop_diastolic_pressure_text);
			mUpload_text.setText(Html.fromHtml(getStringText("本月共上传数据")+getStringData("90")+getStringText("条,平均每天")+getStringData("3")+getStringText("条")));
			mSystolic_pressure_text.setText(Html.fromHtml(getStringText("其中收缩压正常")+getStringData("80")+getStringText("条,正常高值")+getStringData("5")
					+getStringText("条,升高")+getStringData("5")+getStringText("条.   ")+getStringText("正常率：")+getStringData("73%")));
			mDiastolic_pressure_text.setText(Html.fromHtml(getStringText("其中舒张压正常")+getStringData("78")+getStringText("条,正常高值")+getStringData("8")
					+getStringText("条,升高")+getStringData("6")+getStringText("条.   ")+getStringText("正常率：")+getStringData("71%")));*/
		}
	};
	/**
	 * 条数
	 * @param count
	 * @return
	 */
	private String getStringData(String count){
		   return "<font color=#ff3300>"+count+"</font>";
	}
	
	/**
	 * 字符串
	 * @param text
	 * @return
	 */
	private String getStringText(String text){
		return  "<font color=#333333>"+text+"</font>";
	}
	
	OnClickListener click = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			if(v == mClose_btn){
				closePopWindow();
			}
		}
	};
}
